import 'package:flutter_fitness/app_controller.dart';
import 'package:flutter_fitness/model/db/record_provider.dart';
import 'package:get/get.dart';

class HomeLogic extends GetxController {

  final count = 0.obs;

  @override
  void onInit() {
    super.onInit();
    final userId = Get.find<AppController>().user.value.id;
    if (userId != null) {
      final provider = RecordProvider();
      provider.open().then((value) async {
        int count = await provider.getUserRecordCount(userId);
        this.count.value = count;
        provider.close();
      });
    } else {
      Get.snackbar("提示", "用户未登录");
    }
  }
}
